package org.dromara.common.core.validator;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.dromara.common.core.annotation.DeptExists;
import org.dromara.common.core.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;

public class DeptExistsValidator implements ConstraintValidator<DeptExists, Long> {

    @Autowired
    private DeptService deptService;

    @Override
    public void initialize(DeptExists constraintAnnotation) {
    }

    @Override
    public boolean isValid(Long deptId, ConstraintValidatorContext context) {
        return deptService.checkDeptExist(deptId);
    }
}
